<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns:thSys="">
<div th:replace="admin/module/macros :: head('文章管理')"></div>
<body class="app sidebar-mini rtl">
	<main class="app-content">
	<div th:replace="admin/module/macros :: header"></div>
	<div th:replace="admin/module/macros :: sidebar"></div>
	<div class="app-title">
		<div>
			<h1>
				<i class="fa fa-book"></i>文章管理
			</h1>
		</div>
		<ul class="app-breadcrumb breadcrumb">
			<li class="breadcrumb-item"><i class="fa fa-home fa-lg"></i></li>
			<li class="breadcrumb-item"><a href="/admin/article">文章管理</a></li>
			<li class="breadcrumb-item">所有文章</li>
		</ul>
	</div>
	<!--<div class="row">
		<div class="col-md-12">
			<div class="tile">
				<div class="table-responsive">
					 <div>
						<form class="form-inline" role="form">
							<div class="form-group col-md-2 col-*">
								<label class="form-label ">标题：</label> <input type="text"
									class="form-control">
							</div>
							<div class="form-group col-md-2 col-*">
								<label class="form-label ">分类：</label> <select
									class="form-control">
									<option>请选择</option>
									<option>是啊实打实asdsadsa大</option>
									<option>否</option>
								</select>
							</div>
							<div class="form-group col-md-3 col-*">
								<label class="form-label ">状态：</label> <select
									class="form-control">
									<option>请选择</option>
									<option>原创</option>
									<option>转载</option>
								</select>
								<div class="col-md-1 col-*">
									<button class="btn btn-outline-info" type="submit">查询</button>
								</div>
							</div>
						</form>
					</div>
				</div>
			</div>
		</div>
	</div> -->
	<div class="row">
		<div class="col-md-12">
			<div class="tile">
				<input type="hidden" id="articleId"> <a
					href="/admin/article" th:style="${status==0} ? 'color: #000' : ''"><span>已发布(<th:block
							th:text="${published}"></th:block>)
				</span></a>&nbsp;|&nbsp;&nbsp;<a href="/admin/article?status=1"
					th:style="${status==1} ? 'color: #000': ''"><span>草稿(<th:block
							th:text="${draft}"></th:block>)
				</span></a>&nbsp;|&nbsp;&nbsp;<a href="/admin/article?status=2"
					th:style="${status==2} ? 'color: #000': ''"><span>回收站(<th:block
							th:text="${recycle}"></th:block>)
				</span></a>
				<div class="table-responsive">
					<table class="table table-striped table-bordered table-hover"
						id="article_table">
						<tr>
							<td>文章标题</td>
							<td>所在分类</td>
							<td>标签</td>
							<td>创建时间</td>
							<td>操作</td>
						</tr>
						<tr th:each="article,iterStat : ${info.list}">
							<td th:text="${#strings.abbreviate(article.articleTitle,20)}" class="mt-auto"></td>
							<td th:text="${#strings.abbreviate(article.categorysName,20)}"></td>
							<td th:text="${#strings.abbreviate(article.tagsName,20)}"></td>
							<td
								th:text="${#dates.format(article.articleNewstime,'yyyy/MM/dd HH:mm:ss')}"></td>
							<td th:switch="${article.articleStatus}"><th:block
									th:case="0">
									<a th:href="@{'/post/'+${article.articleUrl}}"
										th:target="_blank" class="btn btn-outline-primary btn-sm">查看</a>
									<a th:href="@{/admin/article/edit(article_id=${article.id})}"
										class="btn btn-outline-info btn-sm">编辑</a>
									<button
										th:onclick="'javascript:recycleModel('+${article.id}+')'"
										class="btn btn-outline-danger btn-sm">丢弃</button>
								</th:block> <th:block th:case="1">
									<a th:href="@{/admin/article/edit(article_id=${article.id})}"
										class="btn btn-outline-primary btn-sm">编辑</a>
									<button th:onclick="'javascript:restore('+${article.id}+')'"
										class="btn btn-outline-info btn-sm">发布</button>
									<button
										th:onclick="'javascript:recycleModel('+${article.id}+')'"
										class="btn btn-outline-danger btn-sm">丢弃</button>
								</th:block> <th:block th:case="2">
									<button th:onclick="'javascript:restore('+${article.id}+')'"
										class="btn btn-outline-primary btn-sm">还原</button>
									<button th:onclick="'javascript:showModel('+${article.id}+')'"
										class="btn btn-outline-danger btn-sm">彻底删除(不可逆)</button>
								</th:block></td>
						</tr>
						<tr th:unless="${info.list.total} != 0">
							<td th:text="暂无文章" th:attr="colspan='7',align='center'"></td>
						</tr>
					</table>
				</div>
				<div th:replace="admin/module/macros :: pageArticle(${info},${status})"></div>
			</div>
		</div>
	</div>
	</main>
	<div th:replace="admin/module/macros :: remove"></div>
	<div th:replace="admin/module/macros :: recycle"></div>
	<div th:replace="admin/module/macros :: comm"></div>
	<script type="text/javascript">
		function recycleModel(id) {
			$("#articleId").val(id);
			$("#recycleModal").modal();
		}
		function recycle() {
			window.location.href = "/admin/article/recycle?id="
					+ $("#articleId").val();
		}
		function showModel(id) {
			$("#articleId").val(id);
			$("#removeModal").modal();
		}
		function remove() {
			window.location.href = "/admin/article/remove?id="
					+ $("#articleId").val();
		}
		function restore(id) {
			$.ajax({
				url : "/admin/article/restore",
				type : "post",
				data : {
					id : id
				},
				dataType : "json",
				success : function(data) {
					if (data.flag == true) {
						window.location.reload();
					} else {
						showMsg(data.msg, "error", "3000");
					}
				}
			});
		}
	</script>
</body>
</html>